//
//  StatusToolbar.swift
//  
//
//  Created by 黄礼潮 on 16/3/2.
//
//

import UIKit

class StatusToolbar: UIView {
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupPictuerUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    //添加控件属性
    /// 转发按钮
    private let retweetedButton = UIButton(
        cz_butitle: " 转发",
        fontSize: 12,
        imageName: "timeline_icon_retweet",
        backImageName: "timeline_card_bottom_background")
    /// 评论按钮
    private let commentButton = UIButton(
        cz_butitle: " 评论",
        fontSize: 12,
        imageName: "timeline_icon_comment",
        backImageName: "timeline_card_bottom_background")
    /// 点赞按钮
    private let likeButton = UIButton(
        cz_butitle: " 赞",
        fontSize: 12,
        imageName: "timeline_icon_unlike",
        backImageName: "timeline_card_bottom_background")

    
}


extension StatusToolbar{
    
    private func setupPictuerUI(){
        
        backgroundColor = UIColor.whiteColor()
        
        //加到视图上
        addSubview(retweetedButton)
        addSubview(commentButton)
        addSubview(likeButton)
        //自动布局
        retweetedButton.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(self)
            make.top.equalTo(self)
            make.bottom.equalTo(self)
          
            
        }
        
        
        commentButton.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(retweetedButton.snp_right)
            make.top.equalTo(retweetedButton)
            make.bottom.equalTo(retweetedButton)
            make.width.equalTo(retweetedButton)
            
        }
       
        likeButton.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(commentButton.snp_right)
            make.top.equalTo(commentButton)
            make.bottom.equalTo(commentButton)
            make.width.equalTo(commentButton)
            //右侧参照
            make.right.equalTo(self)
        }
        
        let sep1 = UIImageView(cz_imageName: "timeline_card_bottom_line")
        let sep2 = UIImageView(cz_imageName: "timeline_card_bottom_line")
        
        addSubview(sep1)
        addSubview(sep2)
        
       sep1.snp_makeConstraints { (make) -> Void in
        make.left.equalTo(retweetedButton.snp_right)
        make.centerY.equalTo(retweetedButton)
        }
        
        sep2.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(commentButton.snp_right)
            make.centerY.equalTo(sep1)
        }
        
        
    }
}